/*
 * Copyright (C) 2018 guomw.Inc. All rights reserved.
 * 项目名称： report-manage
 * 文件名称： SystemManager.java
 * Date：18-11-5 上午10:54
 * Author: guomw
 */

package com.guomw.report.service.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.guomw.report.common.config.Constant;
import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 系统管理员
 *
 * @author guomw
 * @date 2018/9/17
 */
@Entity
@Data
@Table(name = "bxs_sys_manager",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"userId"})},
        indexes = {@Index(columnList = "parentUserId")})
public class SystemManager {

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_id")
    private Integer userId;

    /**
     * 用户所属角色
     */
    @JoinColumn(name = "role_id")
    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    private SystemRole role;

    /**
     * 所属ID
     */
    @Column(name = "parent_user_id")
    private Integer parentUserId;

    /**
     * 用户名
     */
    @Column(name = "login_name", length = 30)
    private String loginName;

    /**
     * 密码
     */
    @Column(name = "login_pwd", length = 50)
    private String loginPwd;

    /**
     * 用户token--针对客户端使用
     */
    @Column(name = "token", length = 50)
    private String token;

    /**
     * 最后登录时间
     */
    @JsonFormat(pattern = Constant.DATETIME_FORMAT)
    @Column(name = "last_login_time", columnDefinition = "datetime")
    private LocalDateTime lastLoginTime;

    /**
     * 是否启用
     */
    @Column(name = "enable")
    private boolean enable;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = Constant.DATETIME_FORMAT)
    @Column(name = "create_time", columnDefinition = "datetime")
    private LocalDateTime createTime;

}
